package cn.com.qingz.modules.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

import cn.com.qingz.modules.system.service.impl.GeneralServiceImpl;
import cn.com.qingz.modules.user.mapper.BrandMapper;
import cn.com.qingz.modules.user.model.Brand;
import cn.com.qingz.modules.user.service.BrandService;
import cn.com.qingz.modules.user.vo.BrandSearchCondition;

@Service
public class BrandServiceImpl extends GeneralServiceImpl<Brand> implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    public void doAddOrUpdate(Brand brand) {
        if (brand.getBrandId() == null || brand.getBrandId() == 0) {
            mapper.insert(brand);
        } else {
            mapper.updateByPrimaryKey(brand);
        }
    }

    public PageList<Brand> queryForPage(Object condition, int page, int limit) {
        return brandMapper.queryForPage((BrandSearchCondition) condition, new PageBounds(page, limit));
    }

    public void doLocking(String id, String state) {

    }

    @Override
    public Brand findByName(String name) {
        return brandMapper.findByName(name);
    }
}
